//
//  NoDataManager.m
//  ProjectsOne
//
//  Created by iOS开发 on 2018/7/11.
//  Copyright © 2018年 iOS开发. All rights reserved.
//

#import "NoDataManager.h"

@interface NoDataManager ()
@property (nonatomic, strong) UIView *noDataView;
@end

@implementation NoDataManager


static NoDataManager *manager = nil;
+ (instancetype)sharedInstace {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[NoDataManager alloc] init];
    });
    return manager;
}

- (UIView *)noDataView {
    if (!_noDataView) {
        _noDataView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH,  HEIGHT - kCustomNav)];
        
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NoDataView"]];
        [_noDataView addSubview:imageView];
        
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_noDataView).with.offset(165);
            make.centerX.mas_equalTo(_noDataView);
        }];
        
        UILabel *label = [[UILabel alloc] init];
        label.textColor = [UIColor colorWithHexString:@"999999"];
        label.font = [UIFont systemFontOfSize:17];
        label.text = @"哎呦！没有找到数据哦";
        [_noDataView addSubview:label];
        
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(_noDataView);
            make.top.mas_equalTo(imageView.mas_bottom).with.offset(28);
        }];
    }
    return _noDataView;
}

- (void)showNodataViewToAddSubView:(UIView *)subview {
    [subview addSubview:self.noDataView];
}

- (void)hiddenNoDataViewToAddSubView:(UIView *)subview {
    [self.noDataView removeFromSuperview];
}

@end
